<?php
namespace Kuoqi\Interpreter;
class Func{
	static protected $assign,$code;
	static public function execCode($code,$assign){
		self::$assign = $assign;
		self::$code = $code;
		self::__initializate();
		$code = self::$code;
		self::$code = '';
		return 	$code;	
	}
	static public function __initializate(){
		$data=self::$code;
		preg_match_all(self::need(),$data,$arr);
		foreach($arr[0] as $k=>$v){
			$data = str_replace($v,self::replace(substr($arr[1][$k],0,strlen($arr[1][$k])-1)),$data);
		}
		self::$code = $data;
	}
	
	static private function need(){
		return '/\{\:([\s\S]+?\})/';
	}
	static private function replace($val){
		return '<?php echo '.$val.';?>';
	}
}